from pyecharts.charts import Map
from pyecharts import options as opts
from pyecharts.globals import ThemeType

value = [115.4, 121.6, 122, 116, 123.3, 110.4, 118.4, 116.8, 114.3,
         113.2, 111.8, 116.8, 113.4, 113, 121.3, 118.7, 119, 117.6, 113.8,
         115.1, 114.1, 115.2, 112.6, 114.8, 120.2, 118.2, 119.8, 114.7, 115.4,
         114.6, 112.7]
attr = ['甘肃', '广东', '广西', '贵州', '海南',
        '河南', '湖北', '湖南', '宁夏', '青海',
        '陕西', '四川', '西藏', '新疆', '云南',
        '重庆', '北京', '天津', '河北', '山西', '内蒙古',
        '辽宁', '吉林', '黑龙江', '上海', '江苏', '浙江', '安徽', '福建'
    , '江西', '山东']
sequence = list(zip(attr, value))


def map_visualmap(sequence, year) -> Map:
    c = (
        Map()
            .add(year, sequence, "china", )
            .set_global_opts(
            title_opts=opts.TitleOpts(title="地图"),
            visualmap_opts=opts.VisualMapOpts(max_=130, min_=95),
        )
    )
    return c


map = map_visualmap(sequence, '1993')
map.render(path='./test.html')
